<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>购物车</title>
  <style>
    [v-cloak] {
      display: none
    }
  </style>
</head>
<body>
<div id="app" v-cloak>

</div>

</body>
<script src="../node_modules/vue/dist/vue.js"></script>
<!-- 基于promise的 -->
<script src="5.promise-ajax.js"></script>
<script>
  //1.使用变量时需要初始化，否则新加的属性不会导致页面刷新
  let vm = new Vue({
    el: '#app',
    created() { //数据被初始化后被调用,this指向也是vm
      console.log("1",this.products)
      ajax({url:'./3.cart.json'}).then((res) => {
        console.log(res);
      },(err) =>{

      })
    },
    data: {
      products: []
    }
  })

</script>
</html>
